import configparser

from common_operation.project_conf import PROJECT_FILE


class ParseConfigRobot(object):
    def __init__(self, search_from_file=None):
        self.config_robot = configparser.ConfigParser()
        if search_from_file is None:
            self.ini_file_path = PROJECT_FILE['default_tag_conf']
        else:
            self.ini_file_path = search_from_file
        print(f"""tag配置文件：{self.ini_file_path}""")
        self.read_ini_file()

    def read_ini_file(self):
        """
        读取ini配置文件
        :param ini_file_path:
        :return:
        """
        self.config_robot.read(self.ini_file_path)

    def get_str_value(self, section_key, option_key):
        """
        根据[section_key], option_key=获取str类型的配置value值
        :param section_key:
        :param option_key:
        :return:
        """
        res = self.config_robot.get(section=section_key, option=option_key)
        return res
